import os


def get_path(*saveType, root="TestData", postfix='.txt'):
	path = root
	for string in saveType:
		path += '/' + str(string) 
	path += postfix
	return path

def save_to_file(path, data, mode='a+'):
	filepath, filename = os.path.split(path)
	if not os.path.exists(filepath):	# 不存在则创建目录
		os.makedirs(filepath)
	if not os.path.isdir(filepath):
		print("请清理目录", filepath)
		sys.exit()
	fd = open(path, mode)
	fd.write(data)
	fd.close()


def obj_attribute(obj):
    return '\n'.join(['%s:%s' % item for item in obj.__dict__.items()])